package rpg.visual.window;

import java.awt.Color;
import java.awt.Graphics2D;

import pgui.PVisual;
import pgui.visual.PComponent;
import rpg.visual.VisualImage;

public abstract class VisualWindow extends PComponent {
	public static final int MINIMUM_WIDTH = 32, MINIMUM_HEIGHT = 32;
	
	private VisualWindowHeader header;
	private VisualWindowBorderLeft borderLeft;
	private VisualWindowBorderRight borderRight;
	private VisualWindowBorderTop borderTop;
	private VisualWindowBorderBottom borderBottom;

	public VisualWindow(PVisual visual, String title) {
		super(visual);

		// Header
		header = new VisualWindowHeader(visual, title);
		this.addChild(header);

		// Right Border
		borderRight = new VisualWindowBorderRight(visual);
		this.addChild(borderRight);
		
		// Bottom Border
		borderBottom = new VisualWindowBorderBottom(visual);
		this.addChild(borderBottom);
		
		// Left Border
		borderLeft = new VisualWindowBorderLeft(visual);
		this.addChild(borderLeft);
		
		// Top Border
		borderTop = new VisualWindowBorderTop(visual);
		this.addChild(borderTop);
	}

	// Paint Events
	@Override
	public void onPaint(Graphics2D g) {
		super.onPaint(g);

		// Background
		g.setColor(Color.lightGray);
		VisualImage.opacity(g, 1f);
		g.fillRect(0, 0, this.getLastWidth(), this.getLastHeight());
	}

	// Get & Set
	public VisualWindowHeader getHeader() {
		return header;
	}

	public void setHeader(VisualWindowHeader header) {
		this.header = header;
	}

	public VisualWindowBorderRight getBorderRight() {
		return borderRight;
	}

	public void setBorderRight(VisualWindowBorderRight borderRight) {
		this.borderRight = borderRight;
	}

	public VisualWindowBorderLeft getBorderLeft() {
		return borderLeft;
	}

	public void setBorderLeft(VisualWindowBorderLeft borderLeft) {
		this.borderLeft = borderLeft;
	}

	public VisualWindowBorderBottom getBorderBottom() {
		return borderBottom;
	}

	public void setBorderBottom(VisualWindowBorderBottom borderBottom) {
		this.borderBottom = borderBottom;
	}

	public VisualWindowBorderTop getBorderTop() {
		return borderTop;
	}

	public void setBorderTop(VisualWindowBorderTop borderTop) {
		this.borderTop = borderTop;
	}
}
